package com.ajmd.onlineexam.service;

import com.ajmd.onlineexam.entity.AdminPO;
import com.ajmd.onlineexam.mapper.AdminMapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ajmd
 * @since 2023/5/1 2:00
 */
@Service
public class AdminService {
    @Resource
    private AdminMapper adminMapper;

    public AdminPO findAdminById(String account){
        return adminMapper.selectById(account);
    }

    public int addAdmin(AdminPO adminPO){
        return adminMapper.insert(adminPO);
    }

    public int adminUpdate(AdminPO adminPO){
        UpdateWrapper<AdminPO> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("account",adminPO.getAccount());
        return adminMapper.update(adminPO,updateWrapper);
    }
}
